package com.zhan.utils;

import cn.com.chinatelecom.callcenter.utils.model.CurrentUserInfo;

/**
 * @author 白尚兵
 * @date 2019/11/22 12:42
 **/
public class CurrentUser {
    private static final ThreadLocal<CurrentUserInfo> userInfoContext = new ThreadLocal<>();

    public static Long getUserId() {
        CurrentUserInfo userInfo = getUserInfo();
        if (userInfo != null) {
            return userInfo.getId();
        }
        return null;
    }

    public static void removeUserInfo() {
        userInfoContext.remove();
    }

    public static CurrentUserInfo getUserInfo() {
        return userInfoContext.get();
    }

    public static void setUserInfo(CurrentUserInfo userInfo) {
        userInfoContext.set(userInfo);
    }
}
